import 'package:flutter/material.dart';

class CustomEditWidget extends StatelessWidget {
  TextEditingController controller = TextEditingController();
  final String title;
  final TextInputType inputType;

  CustomEditWidget({
    this.title,
    this.inputType = TextInputType.text,
  });

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => Navigator.pop(context),
      child: Scaffold(
        resizeToAvoidBottomPadding: false,
        backgroundColor: Colors.transparent,
        body: Column(
          children: <Widget>[
            Expanded(
              child: Container(
                child: Center(
                  child: Container(
                    height: 177,
                    width: 270,
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                      color: Colors.white,
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: <Widget>[
                        Padding(
                          padding: EdgeInsets.only(left: 33, top: 24),
                          child: Text(
                            title,
                            style: TextStyle(
                                color: Color(0xff333333), fontSize: 16),
                          ),
                        ),
                        Expanded(
                          child: Container(
                            padding: EdgeInsets.only(
                                top: 8, bottom: 33, left: 33, right: 33),
                            child: Container(
                              padding: EdgeInsets.only(left: 4, bottom: 3),
                              child: TextField(
                                textInputAction: TextInputAction.done,
                                keyboardType: inputType,
                                autofocus: true,
                                controller: controller,
                                style: TextStyle(
                                  fontSize: 15,
                                ),
                                decoration:
                                    InputDecoration(border: InputBorder.none),
                              ),
                              decoration: BoxDecoration(
                                borderRadius:
                                    BorderRadius.all(Radius.circular(4)),
                                border: Border.all(color: Color(0xffc3c3c3)),
                              ),
                            ),
                          ),
                        ),
                        Container(
                          height: 55,
                          padding: EdgeInsets.symmetric(vertical: 7),
                          decoration: BoxDecoration(
                              border: Border(
                                  top: BorderSide(color: Color(0xffefefef)))),
                          child: Row(
                            children: <Widget>[
                              Expanded(
                                child: Container(
                                  child: InkWell(
                                    child: Center(
                                      child: Text(
                                        '取消',
                                        style: TextStyle(
                                            color: Color(0xff333333),
                                            fontSize: 16),
                                      ),
                                    ),
                                    onTap: () => Navigator.pop(context),
                                  ),
                                  decoration: BoxDecoration(
                                      border: Border(
                                          right: BorderSide(
                                              color: Color(0xffefefef)))),
                                ),
                              ),
                              Expanded(
                                child: Container(
                                  child: InkWell(
                                    child: Center(
                                      child: Text(
                                        '保存',
                                        style: TextStyle(
                                            color: Color(0xff2984F8),
                                            fontSize: 16),
                                      ),
                                    ),
                                    onTap: () => Navigator.pop(
                                        context, controller.text),
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
